package com.cecsmsserve.controller;


import com.cecsmsserve.entity.ServiceType;
import com.cecsmsserve.service.IServiceTypeService;
import com.cecsmsserve.util.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王郝浠
 * @since 2024-04-17
 */
@CrossOrigin
@RestController
@RequestMapping("/serviceType")
public class ServiceTypeController {

    @Autowired
    IServiceTypeService serviceTypeService;

    @GetMapping("/selectAllFather")
    public CommonResult selectAllFather(){return serviceTypeService.selectAllFather();}

    @GetMapping("/selectFather1")
    public CommonResult selectFather1(){return serviceTypeService.selectFather1();}

    @GetMapping("/selectAllChildren")
    public CommonResult selectAllChildren(){return serviceTypeService.selectAllChildren();}

    @GetMapping("/selectAllChildrenByFather/{id}")
    public CommonResult selectAllChildrenByFather(@PathVariable("id")int id){
        return serviceTypeService.selectAllChildrenByFather(id);
    }

    @GetMapping("/selectChildren1ByFather/{id}")
    public CommonResult selectChildren1ByFather(@PathVariable("id")int id){
        return serviceTypeService.selectChildren1ByFather(id);
    }

    @PutMapping("/insert")
    public CommonResult insert(@RequestBody ServiceType serviceType){
        return serviceTypeService.insert(serviceType);
    }

    @PostMapping("/update")
    public CommonResult update(@RequestBody ServiceType serviceType){
        return serviceTypeService.update(serviceType);
    }

}
